Skip to content

fix: resolve relative imports for optimized source files (fix #23430) - #23432

Closed
DaZuiZui wants to merge 1 commit into
vitejs:mainfrom
DaZuiZui:codex/fix-optimizedeps-relative-source
Closed

fix: resolve relative imports for optimized source files (fix #23430)#23432
DaZuiZui wants to merge 1 commit into
vitejs:mainfrom
DaZuiZui:codex/fix-optimizedeps-relative-source

Conversation

@DaZuiZui

@DaZuiZui DaZuiZui commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • resolve relative imports to source files listed in optimizeDeps.include to their optimized dep entry
  • match optimized metadata by the final resolved source path, including extensionless relative imports
  • preserve special query handling for ?raw, workers, and URLs
  • add a regression test covering a project source file imported relatively

Cause

optimizeDeps.include already resolved and pre-bundled the source file, but the dev optimizer resolver only checked optimized metadata for bare specifiers. Relative imports went through the normal filesystem path and continued to serve source modules, leaving the generated pre-bundle unused.

Fixes #23430

Tests

  • pnpm --filter vite build-bundle
  • pnpm test-serve playground/optimize-deps/__tests__/optimize-deps.spec.ts
  • pnpm test-build playground/optimize-deps/__tests__/optimize-deps.spec.ts
  • pnpm --filter vite typecheck
  • pnpm exec eslint packages/vite/src/node/plugins/resolve.ts playground/optimize-deps/__tests__/optimize-deps.spec.ts

@bluwy bluwy added the bot: likely Likely a bot, LLM, or agent. Automatically comments and closes the issue or PR label Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

The PR has been manually labeled as likely to be created by a bot, LLM, or agent, and will be automatically closed. This may be because the PR contains LLM-generated descriptions, does not follow the PR template, is overly verbose, or does not contain any fruitful interaction, which harms the review process. Please read our AI policy for more information.

If you believe this is a mistake, please reply to this comment and we will review it.

@github-actions github-actions Bot closed this Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot: likely Likely a bot, LLM, or agent. Automatically comments and closes the issue or PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

optimizeDeps.include accepts a project source file and pre-bundles it, but nothing ever resolves to it

2 participants